import json
import pandas as pd

# 读取JSON文件
with open('../data/json/json.json', 'r') as f:
    data = json.load(f)

# 获取数据中需要的字段
fields_to_extract = ['X', 'Y', 'Z']
data_to_extract = [
                    {
                        f: doc['_source'][f] for f in fields_to_extract
                    }
                   for doc in data
                  ]

# 将数据转换为Pandas数据帧
df = pd.DataFrame(data_to_extract)

# 将数据导出为Excel文件
df.to_excel('../data/excel/output.xlsx', index=False)
